<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="author" content="order by dede58.com"/>
    <title>商品详情</title>
    <link rel="stylesheet" type="text/css" href="./css/style.css">
</head>
<body>

<!-- start header -->
<header>
    <div class="top center">
        <div class="left fl">
            <ul>
                <li><a href="./index.html">首页</a></li>

                <div class="clear"></div>
            </ul>
        </div>
        <div id="not_login" class="right fr">
            <div class="gouwuche fr"><a href="./person_center/self_info.html">个人中心</a></div>
            <div class="fr">
                <ul>
                    <li><a href="./login.html" target="_blank">登录</a></li>
                    <li>|</li>
                    <li><a href="./register.html" target="_blank">注册</a></li>

                </ul>
            </div>
            <div class="clear"></div>
        </div>
        <div id="had_login" class="right fr">
            <div class="gouwuche fr"><a href="./person_center/self_info.html">个人中心</a></div>
            <div class="fr">
                <ul>
                    <li id="myProfile"></li>
                    <li><a id='userName' href="./person_center/self_info.html" target="_blank"></a></li>
                    <li>|</li>
                    <li><a href="./login.html" target="_blank">注销</a></li>

                </ul>
            </div>
            <div class="clear"></div>
        </div>
        <div class="clear"></div>
    </div>
</header>
<div class="danpin center"style="margin-top: 0px">

    <div class="biaoti center"style="margin-top: 0px">onLine校园购物平台</div>
    <div id="lis">
    </div>
</div>

<footer class="myfooter">
    <span>copyright @ 2018 online</span>
</footer>
</body>

<script src="js/crabapple.js" type="text/javascript"></script>
<script>
    if (getCookie('userId') != null) {
        document.getElementById('userName').innerText = getCookie('userName')
        document.getElementById('not_login').style.display = 'none'
        document.getElementById("myProfile").innerHTML="<img style='width: 25px;height: 25px;border-radius:25px;vertical-align: middle;' src=\""+prime_url+"profile\\"+getCookie('userId')+".jpg"+"\">"

    }
    else
        document.getElementById('had_login').style.display = 'none'

    let shopId

    getGoods()

    function getGoods() {
        let xmlhttplogin = new XMLHttpRequest();
        xmlhttplogin.onreadystatechange = function () {
            if (xmlhttplogin.readyState == 4 && xmlhttplogin.status == 200) {
                let re = JSON.parse(xmlhttplogin.responseText);

                if (re.success == true) {
                    console.log(re)
                    let content = ''
                    let item = re.shopList[0]
                    setCookie('sellerId',item.sellerId,1)
                    content += getDetailGoods(item.shopId, item.shopName, item.shopInfo)
                    shopId = item.shopId
                    upHistory()
                    document.getElementById('lis').innerHTML = content

                }
                else alert(re.errMsg)
            }
        }
        xmlhttplogin.open("GET", prime_url + 'shop/listshopspageinfo?shopName=' + getCookie('shopName'), true);
        xmlhttplogin.setRequestHeader('Content-Type', 'application/json')
        xmlhttplogin.send();
    }


    /**
     * 添加浏览历史
     */
    function upHistory() {
        let xmlhttphis = new XMLHttpRequest();
        xmlhttphis.onreadystatechange = function () {
            if (xmlhttphis.readyState == 4 && xmlhttphis.status == 200) {
                let re = JSON.parse(xmlhttphis.responseText);
                if (re.success == true)
                {
                    console.log("添加历史记录成功")
                    console.log(re)
                }
                else alert(re.errMsg)
            }
        }
        xmlhttphis.open("GET", prime_url + 'history/addshopinfotohistory?shopId=' + 8 + "&userId=" + getCookie('userId'), true);
        xmlhttphis.setRequestHeader('Content-Type', 'application/json')
        xmlhttphis.send();
    }
</script>
</html>